using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HermesPortal.Core;  
public partial class Saga_Controls_SagaEdit : System.Web.UI.UserControl
{

    private int _sagaId = 0;
    public int SagaID
    {
        get { return _sagaId; }
        set { _sagaId = value; }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!Page.IsPostBack)
        { BindControls(); }

         
            string sPath = "~/fckeditor/"; 

            fckCurrentAffiars.BasePath = sPath;
            fckSummary.BasePath = sPath;
            fckFormation.BasePath = sPath;

            string imageBrowser = sPath + "editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connector.aspx";
            string linkBrowserUrl = sPath + "editor/filemanager/browser/default/browser.html?Connector=connectors/aspx/connector.aspx";
            
            fckCurrentAffiars.ImageBrowserURL = imageBrowser;
            fckCurrentAffiars.LinkBrowserURL = linkBrowserUrl;
            fckCurrentAffiars.PluginsPath = sPath + "plugins/";

            fckSummary.ImageBrowserURL = imageBrowser;
            fckSummary.LinkBrowserURL = linkBrowserUrl;
            fckSummary.PluginsPath = sPath + "plugins/";

            fckFormation.ImageBrowserURL = imageBrowser;
            fckFormation.LinkBrowserURL = linkBrowserUrl;
            fckFormation.PluginsPath = sPath + "plugins/";
        
      
    }

    private void BindControls()
    {
        Saga saga = SagaServices.GetSaga(SagaID);

        txtTitle.Text = saga.Name;
        txtTageline.Text = saga.TagLine;
        fckCurrentAffiars.Value = saga.CurrentAffairs;
        fckSummary.Value = saga.SagaSummary;
        fckFormation.Value = saga.FormationStory;

    }

    /// <summary>
    /// Save Saga changes 
    /// </summary>
    public void SaveSagaChanges()
    {
        Saga saga = SagaServices.GetSaga(SagaID);
        saga.Name = txtTitle.Text;
        saga.TagLine  = txtTageline.Text;
        saga.CurrentAffairs = fckCurrentAffiars.Value;
        saga.SagaSummary = fckSummary.Value;
        saga.FormationStory = fckFormation.Value;

        SagaServices.UpdateSaga(saga);
        BindControls();
    }

}
